package com.echo.util;

import java.util.SortedSet;
import java.util.TreeSet;


public class SystemWebConstant {
	
	public static final Integer DEFAULT_PAGE_SIZE = 10;//每页的数据
	
	public final static Integer INVALID = 0x000;// 0
	
	public final static Integer MONDAY = 0x001;// 1
	
	public final static Integer TUESDAY = 0x002;// 2
	
	public final static Integer WENDNESDAY = 0x004;// 4
	
	public final static Integer THURSDAY = 0x008;// 8
	
	public final static Integer FRIDAY = 0x010;// 16
	
	public final static Integer SATURDAY = 0x020;// 32
	
	public final static Integer SUNDAY = 0x040;// 64
	
	public final static int ANONYMOUS = 0x0000; // 0 匿名
    // 用户角色
	public final static int REGISTER_USER = 0x0001; // 1 注册

	public final static int CAR_CLUB = 0x0002; // 2 车友

	public final static int INFORMATION_PROVIDER = 0x0004; // 4 导航员

	public final static int DISC_JOCKEY = 0x0008; // 8 主持人

	public final static int DISC_JOCKEY_PUBLIC = 0x0010; // 16 公共账户

	public final static int LOCATION_EDITOR = 0x0020; // 32 路况编辑员

	public final static int TRAFFIC_EDITOR = 0x0040; // 64 路况编辑员

	public final static int ACTION_EDITOR = 0x0080; // 128 活动编辑员

	public final static int NEWS_EDITOR = 0x0100; // 256 新闻编辑员

	public final static int PROGRAM_EDITOR = 0x0200; // 512 节目导播员

	public final static int INNER_COMM = 0x0400; // 1024 内部客户标识

	public final static int PRIZE_EDITOR = 0x0800; // 2048 奖池编辑员

	public final static int USER_BLACKED = 0x8000; // 32768 限制客户
	
	public final static int  USER_PHONE     = 1;
	
	public final static int  USER_NAME      = 2;
	
	public final static int  USER_LABEL     = 3;
	
	public final static int  USER_STATUS    = 4;
	
	public final static int  USER_CAR       = 5;
	
	public final static int  USER_EMAIL     = 6;
	
	public final static int  USER_GENDER    = 7;
	
	
	public static String prasePlayPeriodText(Integer playPeriod){
		String binaryPlayPeriod = Integer.toBinaryString(playPeriod);
		String textPlayPeriod = "";
		int binaryLength = binaryPlayPeriod.length();
		int indexFromLast = 0;
		for(int i=binaryLength;i>0;i--){
			indexFromLast++;
			if("1".equals(binaryPlayPeriod.substring(i-1, i))){
				switch (indexFromLast) {
				case 1:
					textPlayPeriod +=",每周一";
					break;
				case 2:
					textPlayPeriod +=",每周二";
					break;
				case 3:
					textPlayPeriod +=",每周三";
					break;
				case 4:
					textPlayPeriod +=",每周四";
					break;
				case 5:
					textPlayPeriod +=",每周五";
					break;
				case 6:
					textPlayPeriod +=",每周六";
					break;
				case 7:
					textPlayPeriod +=",每周日";
					break;
				default:
					textPlayPeriod +="";
					break;
				}
			}
			
		}
		if(!"".equals(textPlayPeriod)){
			textPlayPeriod = textPlayPeriod.substring(1);
		}
		return textPlayPeriod;
	}
	
	public static SortedSet<Integer> prasePlayPeriodSet(Integer playPeriod){
		String binaryPlayPeriod = Integer.toBinaryString(playPeriod);
		SortedSet<Integer> playPeriodSet = new TreeSet<Integer>();
		int binaryLength = binaryPlayPeriod.length();
		int indexFromLast = 0;
		for(int i=binaryLength;i>0;i--){
			indexFromLast++;
			if("1".equals(binaryPlayPeriod.substring(i-1, i))){
				switch (indexFromLast) {
				case 1:
					playPeriodSet.add(MONDAY);
					break;
				case 2:
					playPeriodSet.add(TUESDAY);
					break;
				case 3:
					playPeriodSet.add(WENDNESDAY);
					break;
				case 4:
					playPeriodSet.add(THURSDAY);
					break;
				case 5:
					playPeriodSet.add(FRIDAY);
					break;
				case 6:
					playPeriodSet.add(SATURDAY);
					break;
				case 7:
					playPeriodSet.add(SUNDAY);
					break;
				default:
					playPeriodSet.add(INVALID);
					break;
				}
			}
			
		}

		return playPeriodSet;
	}
	
}
